#include<ros/ros.h>
#include<geometry_msgs/Twist.h>
#include<std_msgs/Float32.h>

float b=0.128;
float v, w;

ros::Publisher r_pub;
ros::Publisher l_pub;

void callback(const geometry_msgs::Twist& cmd_vel)
{
    std_msgs::Float32 vr;
    std_msgs::Float32 vl;
    v=cmd_vel.linear.x;
    w=cmd_vel.angular.z;
    vr.data=0.5*(2.0*v+b*w);
    vl.data=0.5*(2.0*v-b*w);
    r_pub.publish(vr);
    l_pub.publish(vl);
}

int main(int argc, char** argv)
{
    ros::init(argc,argv,"q3_3b");
    ros::NodeHandle n;
    ros::Subscriber sub_a=n.subscribe("send_3a",1000,callback);
    ros::Publisher r_pub=n.advertise<std_msgs::Float32>("vel_r",20);
    ros::Publisher l_pub=n.advertise<std_msgs::Float32>("vel_l",20);
    ros::spin();
    return 1;
}